"""
权限管理视图
"""
from rest_framework.response import Response
from django.contrib.auth.models import Permission, ContentType
from rest_framework.viewsets import ModelViewSet
from meiduo_admin.serializers.permission_serializers import *
from meiduo_admin.paginations import MyPage

class PermissionView(ModelViewSet):
    queryset = Permission.objects.all()
    serializer_class =  PermissionSerializer
    pagination_class = MyPage

    # 排序
    def get_queryset(self):
        return self.queryset.order_by('pk')


    def content_types(self, request):
        content = ContentType.objects.all()
        serializer = ContentTypeSerializer(instance=content, many=True)
        return Response(serializer.data)
